package com.zxl.diy.weather.model;

import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

import com.zxl.diy.weather.model.bean.City;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/11/5.
 */

public class SearchCityInChinese {

    public static List<City> searchCityInChinese(Context context, String keyword) {
        List<City> lstSearch = new ArrayList<>();
        String sql = "select * from city where name like ? or pinyin like ?";
        Cursor cursor = null;
        SQLiteDatabase database = null;
        try {
            database = SQLiteDatabase.openOrCreateDatabase(PheadHelper.initDb(context), null);
            if (database != null) {
                cursor = database.rawQuery(sql, new String[] { keyword + "%", keyword + "%" });
                while (cursor != null && cursor.moveToNext()) {
                    City city = new City();
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (cursor != null) {
                cursor.close();
            }
            if (database != null && database.isOpen()) {
                database.close();
            }
        }
        return lstSearch;
    }

}
